package arithmetic.jinritoutiao1.taotiao1;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        HashSet<Integer> a = new HashSet<Integer>();
        HashSet<Integer> b = new HashSet<Integer>();
        for (int i = 0; i < n; i++) {
            int value = sc.nextInt();
            if (!a.add(value)) {
                b.add(value);
            }
        }
        if (k == 0) {
            System.out.println(b.size());
            return;
        }
        // ������ȥ�ظ�
        int ans = 0;
        Object[] array = a.toArray();
        Arrays.sort(array);
        for (int i = array.length - 1; i > 0; i--) {
            for (int j = array.length - 2; j >= 0; j--) {
                int temp = (Integer) array[i] - (Integer) array[j];
                if (temp > k) {
                    break;
                } else if (temp == k) {
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}
/*
 *
 *
 * */

/**
 * Created by jiangfeng on 2018/3/24. [������1|10��] �ҵ���ֵΪk�����ֶԵĸ��� ��һ�У�n��k��n��ʾ���ָ�����k��ʾ��ֵ �ڶ��У�n��������
 * <p>
 * ��ֵΪk�����ֶ�ȥ�غ�ĸ���
 * <p>
 * ���磺 5 2 1 5 3 4 2 ��� 3
 */